import About from "../models/aboutModel.js";

export default class AboutController {
  static async apiUpdateAbout(req, res, next) {
    try {
      const { description } = req.body;
      var data = await About.findOne({});
      if(data) {
        data.description = description;
      } else {
        data = new About({description});
      }
      await data.save();
      res.status(200).json({});
    } catch (e) {
      res.status(500).json({ error: e.message });
    }
  }

  static async apiGetAbout(req, res, next) {
    try {
      const about = await About.findOne({});
      res.status(200).json({about});
    } catch (e) {
      res.status(500).json({ error: e.message });
    }
  }
}
